package com.ruoyi.easyfame.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.easyfame.domain.DemandManagements;
import com.ruoyi.easyfame.service.IDemandManagementsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 需求管理记录Controller
 * 
 * @author xhb
 * @date 2025-08-27
 */
@RestController
@RequestMapping("/easyfame/managements")
public class DemandManagementsController extends BaseController
{
    @Autowired
    private IDemandManagementsService demandManagementsService;

    /**
     * 查询需求管理记录列表
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:list')")
    @GetMapping("/list")
    public TableDataInfo list(DemandManagements demandManagements)
    {
        startPage();
        List<DemandManagements> list = demandManagementsService.selectDemandManagementsList(demandManagements);
        return getDataTable(list);
    }

    /**
     * 导出需求管理记录列表
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:export')")
    @Log(title = "需求管理记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DemandManagements demandManagements)
    {
        List<DemandManagements> list = demandManagementsService.selectDemandManagementsList(demandManagements);
        ExcelUtil<DemandManagements> util = new ExcelUtil<DemandManagements>(DemandManagements.class);
        util.exportExcel(response, list, "需求管理记录数据");
    }

    /**
     * 获取需求管理记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(demandManagementsService.selectDemandManagementsById(id));
    }

    /**
     * 新增需求管理记录
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:add')")
    @Log(title = "需求管理记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DemandManagements demandManagements)
    {
        return toAjax(demandManagementsService.insertDemandManagements(demandManagements));
    }

    /**
     * 修改需求管理记录
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:edit')")
    @Log(title = "需求管理记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DemandManagements demandManagements)
    {
        return toAjax(demandManagementsService.updateDemandManagements(demandManagements));
    }

    /**
     * 删除需求管理记录
     */
    @PreAuthorize("@ss.hasPermi('easyfame:managements:remove')")
    @Log(title = "需求管理记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(demandManagementsService.deleteDemandManagementsByIds(ids));
    }
}
